#{extends 'main.html' /}
#{set title:'Show rides' /}

<link href="@{'/public/css/main.css'}" rel="stylesheet" type="text/css" />
<link href="@{'/public/css/tables.css'}" rel="stylesheet" type="text/css" />

#{form @search()}
	<h2>Search Results:</h2>

 	<table class="hor-minimalist-a" style="width: 95%">
        <thead>
            <tr valign="middle">
                <th align="center">Name of driver</th>
                <th align="center">Start point</th>
                <th align="center">Dest. campus</th>
                #{if !numberOfMatches}
                	<th align="center">Date</th>
                #{/if}
                #{if numberOfMatches}
                	<th align="center">No. Drives</th>
                #{/if}
                <th align="center">Seats</th>
                <th align="center">Regularity</th>
                <th align="center">Action</th>
            </tr>
        </thead>
        <tbody>
            #{list rides, as:'ride'}
                <tr valign="middle">
                    <td align="center">${ride.driver.username}</td>
                    <td align="center">${ride.startPoint}</td>
                    <td align="center">${unis.destinationCampusMap.get(ride.destinationCampusId)}</td>
                    #{if !numberOfMatches}
                	<td align="center">${ride.rideDate}</td>
	                #{/if}
	                #{if numberOfMatches}
	                	<td align="center">${numberOfMatches}</td>
	                #{/if}
                    <td align="center">${ride.numOfSeatsAvailable }</td>
                    <td align="center">${unis.regularityList.get(ride.regularity)}</td>
                    <td align="center"><a href="@{show(ride.id)}">Show ride</a></td>
                </tr>
            #{/list}
            	<tr></tr>
            	<tr>
            		<td><input type="submit" style="width:120px;" name="search" value="Back to Search"></td>
            	</tr>
        </tbody>
    </table> 
#{/form}